<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    var minimumAbsDifference = function (arr) {
        let sortArr = arr.sort((a, b) => { return a - b }) //升序排列
        let res = []
        let cz = sortArr[1] - sortArr[0] //第一对相邻元素的差值
        // 遍历相邻两个元素，计算差值
        for (let i = 0; i < sortArr.length - 1; i++) {
            if (cz > sortArr[i + 1] - sortArr[i]) {
                cz = sortArr[i + 1] - sortArr[i]
                res = []
                res.push([sortArr[i], sortArr[i + 1]])
            }
            else if (cz === sortArr[i + 1] - sortArr[i]) {
                res.push([sortArr[i], sortArr[i + 1]])
            }
        }
        return res
    };
</script>